home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / ds5000.md / machMon.h < prev    next >
C/C++ Source or Header  |  1991-03-05  |  9KB  |  287 lines

  1. /*
  2.  * machMon.h --
  3.  *
  4.  *    Structures, constants and defines for access to the pmax prom.
  5.  *
  6.  *    Copyright (C) 1989 Digital Equipment Corporation.
  7.  *    Permission to use, copy, modify, and distribute this software and
  8.  *    its documentation for any purpose and without fee is hereby granted,
  9.  *    provided that the above copyright notice appears in all copies.
  10.  *    Digital Equipment Corporation makes no representations about the
  11.  *    suitability of this software for any purpose.  It is provided "as is"
  12.  *    without express or implied warranty.
  13.  *
  14.  * $Header: /sprite/src/kernel/mach/ds5000.md/RCS/machMon.h,v 1.4 91/03/05 15:06:33 jhh Exp $ SPRITE (Berkeley)
  15.  */
  16.  
  17. #ifndef _MACHMON
  18. #define _MACHMON
  19.  
  20. /*
  21.  * The prom routines use the following structure to hold strings.
  22.  */
  23. typedef struct {
  24.     char    *argPtr[16];    /* Pointers to the strings. */
  25.     char    strings[256];        /* Buffer for the strings. */
  26.     char    *end;        /* Pointer to end of used buf. */
  27.     int     num;        /* Number of strings used. */
  28. } MachStringTable;
  29.  
  30. MachStringTable    MachMonBootParam;    /* Boot command line. */
  31.  
  32. /*
  33.  * The prom has a jump table at the beginning of it to get to its
  34.  * functions.
  35.  */
  36. #define MACH_MON_JUMP_TABLE_ADDR    0xBFC00000
  37.  
  38. /*
  39.  * Default reboot string.
  40.  */
  41. #define DEFAULT_REBOOT    "tftp()ds5000"
  42.  
  43. /*
  44.  * The jump table.
  45.  */
  46. typedef struct Mach_MonFuncs {
  47.     int        (*reset)();
  48.     int        (*exec)();
  49.     int        (*restart)();
  50.     int        (*reinit)();
  51.     int        (*reboot)();
  52.     int        (*autoboot)();
  53.     int        (*open)();
  54.     int        (*read)();
  55.     int        (*write)();
  56.     int        (*ioctl)();
  57.     int        (*close)();
  58.     int        (*lseek)();
  59.     int        (*mgetchar)();
  60.     int        (*mputchar)();
  61.     int        (*showchar)();
  62.     int        (*gets)();
  63.     int        (*puts)();
  64.     int        (*printf)();
  65.     int        (*mem1)();
  66.     int        (*mem2)();
  67.     int        (*save_regs)();
  68.     int        (*load_regs)();
  69.     int        (*jump_s8)();
  70.     char *    (*getenv2)();
  71.     int        (*setenv2)();
  72.     int        (*atonum)();
  73.     int        (*strcmp)();
  74.     int        (*strlen)();
  75.     char *    (*strcpy)();
  76.     char *    (*strcat)();
  77.     int        (*get_cmd)();
  78.     int        (*get_nums)();
  79.     int     (*argparse)();
  80.     int        (*help)();
  81.     int        (*dump)();
  82.     int        (*setenv)();
  83.     int        (*unsetenv)();
  84.     int        (*printenv)();
  85.     int        (*jump2_s8)();
  86.     int        (*enable)();
  87.     int        (*disable)();
  88.     int        (*zero_buf)();
  89. #ifdef ds5000
  90.     int        (*halt)();
  91. #endif
  92. } Mach_MonFuncs;
  93.  
  94. /*
  95.  * Each entry in the jump table is 8 bytes - 4 for the jump and 4 for a nop.
  96.  */
  97. #define MACH_MON_FUNC_ADDR(funcNum)    (MACH_MON_JUMP_TABLE_ADDR+((funcNum)*8))
  98.  
  99. /*
  100.  * The functions:
  101.  *
  102.  *    MACH_MON_RESET        Run diags, check bootmode, reinit.
  103.  *    MACH_MON_EXEC        Load new program image.
  104.  *    MACH_MON_RESTART    Re-enter monitor command loop.
  105.  *    MACH_MON_REINIT        Re-init monitor, then cmd loop.
  106.  *    MACH_MON_REBOOT        Check bootmode, no config.
  107.  *    MACH_MON_AUTOBOOT    Autoboot the system.
  108.  *
  109.  * The following routines access PROM saio routines and may be used by
  110.  * standalone programs that would like to use PROM I/O:
  111.  *
  112.  *    MACH_MON_OPEN        Open a file.
  113.  *    MACH_MON_READ        Read from a file.
  114.  *    MACH_MON_WRITE        Write to a file.
  115.  *    MACH_MON_IOCTL        Iocontrol on a file.
  116.  *    MACH_MON_CLOSE        Close a file.
  117.  *    MACH_MON_LSEEK        Seek on a file.
  118.  *    MACH_MON_GETCHAR    Get character from console.
  119.  *    MACH_MON_PUTCHAR    Put character on console.
  120.  *    MACH_MON_SHOWCHAR    Show a char visibly.
  121.  *    MACH_MON_GETS        gets with editing.
  122.  *    MACH_MON_PUTS        Put string to console.
  123.  *    MACH_MON_PRINTF        Kernel style printf to console.
  124.  *
  125.  * The following are other prom routines:
  126.  *    MACH_MON_MEM1        Do something in memory.
  127.  *    MACH_MON_MEM2        Do something else in memory.
  128.  *    MACH_MON_SAVEREGS    Save registers in a buffer.
  129.  *    MACH_MON_LOADREGS    Get register back from buffer.
  130.  *    MACH_MON_JUMPS8        Jump to address in s8.
  131.  *    MACH_MON_GETENV2    Gets a string from system environment.
  132.  *    MACH_MON_SETENV2    Sets a string in system environment.
  133.  *    MACH_MON_ATONUM        Converts ascii string to number.
  134.  *    MACH_MON_STRCMP        Compares strings (strcmp).
  135.  *    MACH_MON_STRLEN        Length of string (strlen).
  136.  *    MACH_MON_STRCPY        Copies string (strcpy).
  137.  *    MACH_MON_STRCAT        Appends string (strcat).
  138.  *    MACH_MON_GETCMD        Gets a command.
  139.  *    MACH_MON_GETNUMS    Gets numbers.
  140.  *    MACH_MON_ARGPARSE    Parses string to argc,argv.
  141.  *    MACH_MON_HELP        Help on prom commands.
  142.  *    MACH_MON_DUMP        Dumps memory.
  143.  *    MACH_MON_SETENV        Sets a string in system environment.
  144.  *    MACH_MON_UNSETENV    Unsets a string in system environment
  145.  *    MACH_MON_PRINTENV    Prints system environment
  146.  *    MACH_MON_JUMP2S8    Jumps to s8
  147.  *    MACH_MON_ENABLE        Performs prom enable command.
  148.  *    MACH_MON_DISABLE    Performs prom disable command.
  149.  *    MACH_MON_ZEROB        Zeros a system buffer.
  150.  *
  151.  * Routines specific to the ds5000.
  152.  *
  153.  *    MACH_MON_HALT        Halts the system and prints out memory.
  154.  */
  155. #define MACH_MON_RESET        MACH_MON_FUNC_ADDR(0)
  156. #define MACH_MON_EXEC        MACH_MON_FUNC_ADDR(1)
  157. #define MACH_MON_RESTART    MACH_MON_FUNC_ADDR(2)
  158. #define MACH_MON_REINIT        MACH_MON_FUNC_ADDR(3)
  159. #define MACH_MON_REBOOT        MACH_MON_FUNC_ADDR(4)
  160. #define MACH_MON_AUTOBOOT    MACH_MON_FUNC_ADDR(5)
  161. #define MACH_MON_OPEN        MACH_MON_FUNC_ADDR(6)
  162. #define MACH_MON_READ        MACH_MON_FUNC_ADDR(7)
  163. #define MACH_MON_WRITE        MACH_MON_FUNC_ADDR(8)
  164. #define MACH_MON_IOCTL        MACH_MON_FUNC_ADDR(9)
  165. #define MACH_MON_CLOSE        MACH_MON_FUNC_ADDR(10)
  166. #define MACH_MON_LSEEK        MACH_MON_FUNC_ADDR(11)
  167. #define MACH_MON_GETCHAR    MACH_MON_FUNC_ADDR(12)
  168. #define MACH_MON_PUTCHAR    MACH_MON_FUNC_ADDR(13)
  169. #define MACH_MON_SHOWCHAR    MACH_MON_FUNC_ADDR(14)
  170. #define MACH_MON_GETS        MACH_MON_FUNC_ADDR(15)
  171. #define MACH_MON_PUTS        MACH_MON_FUNC_ADDR(16)
  172. #define MACH_MON_PRINTF        MACH_MON_FUNC_ADDR(17)
  173. #define MACH_MON_MEM1        MACH_MON_FUNC_ADDR(28)
  174. #define MACH_MON_MEM2        MACH_MON_FUNC_ADDR(29)
  175. #define MACH_MON_SAVEREGS    MACH_MON_FUNC_ADDR(30)
  176. #define MACH_MON_LOADREGS    MACH_MON_FUNC_ADDR(31)
  177. #define MACH_MON_JUMPS8        MACH_MON_FUNC_ADDR(32)
  178. #define MACH_MON_GETENV2    MACH_MON_FUNC_ADDR(33)
  179. #define MACH_MON_SETENV2    MACH_MON_FUNC_ADDR(34)
  180. #define MACH_MON_ATONUM        MACH_MON_FUNC_ADDR(35)
  181. #define MACH_MON_STRCMP        MACH_MON_FUNC_ADDR(36)
  182. #define MACH_MON_STRLEN        MACH_MON_FUNC_ADDR(37)
  183. #define MACH_MON_STRCPY        MACH_MON_FUNC_ADDR(38)
  184. #define MACH_MON_STRCAT        MACH_MON_FUNC_ADDR(39)
  185. #define MACH_MON_GETCMD        MACH_MON_FUNC_ADDR(40)
  186. #define MACH_MON_GETNUMS    MACH_MON_FUNC_ADDR(41)
  187. #define MACH_MON_ARGPARSE    MACH_MON_FUNC_ADDR(42)
  188. #define MACH_MON_HELP        MACH_MON_FUNC_ADDR(43)
  189. #define MACH_MON_DUMP        MACH_MON_FUNC_ADDR(44)
  190. #define MACH_MON_SETENV        MACH_MON_FUNC_ADDR(45)
  191. #define MACH_MON_UNSETENV    MACH_MON_FUNC_ADDR(46)
  192. #define MACH_MON_PRINTENV    MACH_MON_FUNC_ADDR(47)
  193. #define MACH_MON_JUMP2S8    MACH_MON_FUNC_ADDR(48)
  194. #define MACH_MON_ENABLE        MACH_MON_FUNC_ADDR(49)
  195. #define MACH_MON_DISABLE    MACH_MON_FUNC_ADDR(50)
  196. #define MACH_MON_ZEROB        MACH_MON_FUNC_ADDR(51)
  197.  
  198. #ifdef ds5000
  199. #define MACH_MON_HALT        MACH_MON_FUNC_ADDR(54)
  200. #endif
  201.  
  202. #ifdef _MONFUNCS
  203. Mach_MonFuncs mach_MonFuncs = {
  204.     (int (*)()) MACH_MON_RESET,
  205.     (int (*)()) MACH_MON_EXEC,
  206.     (int (*)()) MACH_MON_RESTART,
  207.     (int (*)()) MACH_MON_REINIT,
  208.     (int (*)()) MACH_MON_REBOOT,
  209.     (int (*)()) MACH_MON_AUTOBOOT,
  210.     (int (*)()) MACH_MON_OPEN,
  211.     (int (*)()) MACH_MON_READ,
  212.     (int (*)()) MACH_MON_WRITE,
  213.     (int (*)()) MACH_MON_IOCTL,
  214.     (int (*)()) MACH_MON_CLOSE,
  215.     (int (*)()) MACH_MON_LSEEK,
  216.     (int (*)()) MACH_MON_GETCHAR,
  217.     (int (*)()) MACH_MON_PUTCHAR,
  218.     (int (*)()) MACH_MON_SHOWCHAR,
  219.     (int (*)()) MACH_MON_GETS,
  220.     (int (*)()) MACH_MON_PUTS,
  221.     (int (*)()) MACH_MON_PRINTF,
  222.     (int (*)()) MACH_MON_MEM1,
  223.     (int (*)()) MACH_MON_MEM2,
  224.     (int (*)()) MACH_MON_SAVEREGS,
  225.     (int (*)()) MACH_MON_LOADREGS,
  226.     (int (*)()) MACH_MON_JUMPS8,
  227.     (char *(*)()) MACH_MON_GETENV2,
  228.     (int (*)()) MACH_MON_SETENV2,
  229.     (int (*)()) MACH_MON_ATONUM,
  230.     (int (*)()) MACH_MON_STRCMP,
  231.     (int (*)()) MACH_MON_STRLEN,
  232.     (char *(*)()) MACH_MON_STRCPY,
  233.     (char *(*)()) MACH_MON_STRCAT,
  234.     (int (*)()) MACH_MON_GETCMD,
  235.     (int (*)()) MACH_MON_GETNUMS,
  236.     (int (*)()) MACH_MON_ARGPARSE,
  237.     (int (*)()) MACH_MON_HELP,
  238.     (int (*)()) MACH_MON_DUMP,
  239.     (int (*)()) MACH_MON_SETENV,
  240.     (int (*)()) MACH_MON_UNSETENV,
  241.     (int (*)()) MACH_MON_PRINTENV,
  242.     (int (*)()) MACH_MON_JUMP2S8,
  243.     (int (*)()) MACH_MON_ENABLE,
  244.     (int (*)()) MACH_MON_DISABLE,
  245.     (int (*)()) MACH_MON_ZEROB,
  246. #ifdef ds5000
  247.     (int (*)()) MACH_MON_HALT,
  248. #endif
  249. };
  250. #else
  251. extern    Mach_MonFuncs    mach_MonFuncs;
  252. #endif
  253.  
  254. /*
  255.  * Functions and defines to access the monitor.
  256.  */
  257.  
  258. extern void Mach_MonAbort _ARGS_((void));
  259. extern int Mach_MonPutChar _ARGS_((int ch));
  260. extern void Mach_MonReboot _ARGS_((char *rebootString));
  261. #define Mach_MonMayPut Mach_MonPutChar
  262.  
  263.  
  264. #define Mach_MonGetChar            (mach_MonFuncs.mgetchar)
  265. #define Mach_MonGetNextChar        (mach_MonFuncs.mgetchar)
  266. #define Mach_MonGetLine            (mach_MonFuncs.gets)
  267. #define Mach_ArgParse(string,table)    Mach_ArgParseCode(string,table)
  268. #define Mach_MonPrintf            (mach_MonFuncs.printf)
  269. #define Mach_MonOpen(name,flags)    (mach_MonFuncs.open)(name,flags)
  270. #define Mach_MonRead(fd,buf,len)    (mach_MonFuncs.read)(fd,buf,len)
  271. #define Mach_MonClose(fd)        (mach_MonFuncs.close)(fd)
  272. #define Mach_MonLseek(fd,offset,mode)    (mach_MonFuncs.lseek)(fd,offset,mode)
  273. #define Mach_MonGetenv(name)        (mach_MonFuncs.getenv2)(name)
  274.  
  275. #ifdef ds5000
  276. #define Mach_MonHalt(addr, wordCnt)    (mach_MonFuncs.halt)(addr, wordCnt)
  277. #define Mach_MonDump(argc, argv)    (mach_MonFuncs.dump)(argc, argv)
  278. #endif
  279.  
  280. /*
  281.  * The nonvolatile ram has a flag to indicate it is usable.
  282.  */
  283. #define MACH_USE_NON_VOLATILE     ((char *)0xbd0000c0)
  284. #define MACH_NON_VOLATILE_FLAG    0x02
  285.  
  286. #endif /* _MACHPROM */
  287.